package com.example.user.user

import com.example.library_base.base.BaseRepository
import com.example.user.imp.Service
import dagger.hilt.android.scopes.ViewModelScoped
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import retrofit2.HttpException
import javax.inject.Inject

@ViewModelScoped
class UserRepository @Inject constructor()
    : BaseRepository<Service>(Service::class.java) {

    suspend fun getRestaurantList(map: Map<String, Any>) = withContext(Dispatchers.IO) {
        try {
            val s = service.getRestaurantList(map)
            s.data
        }catch (e: HttpException){
            println("网络请求错误")
            println(e.message)
            println(e.code())
            println(e.response())
        }

    }

}